<?php
/**
 * 命令选项
 * 
 * @version $Id: ICommandOption.php 312 2008-04-23 16:29:38Z iwind $
 * @package net.4kiki.cli
 */
class ICommandOption extends IObject {
	private $alias = array();
	private $description;
	private $name;
	private $optional = false;
	private $defined = false;
	
	/**
	 * 构造器
	 *
	 * @param string $name 选项名
	 * @param string $description 选项描述
	 * @param boolean $optional 是否可选
	 */
	public function __construct($name, $description = null, $optional = false) {
		$this->setName($name);
		$this->setDescription($description);
		$this->setOptional($optional);
	}
	
	/**
	 * 设置同义选项
	 *
	 * @param ICommandOption $option 选项
	 */
	public function alias(ICommandOption $option) {
		$this->alias[] = $option;
	}
	
	/**
	 * 取得所有同义选项
	 *
	 * @return array
	 */
	public function getAlias() {
		return $this->alias;
	}
	
	/**
	 * 取得选项的描述
	 *
	 * @return string
	 */
	public function getDescription() {
		return $this->description;
	}
	
	/**
	 * 取得选项的名称
	 *
	 * @return string
	 */
	public function getName() {
		return $this->name;
	}
	
	/**
	 * 判断当前对象是否已经被定义
	 *
	 * @return boolean
	 */
	public function isDefined() {
		return $this->defined;
	}
	
	/**
	 * 判断当前选项是否是可选的
	 *
	 * @return boolean
	 */
	public function isOptional() {
		return $this->optional;
	}
	
	/**
	 * 设置描述
	 *
	 * @param string $description 选项的描述
	 */
	public function setDescription($description) {
		$this->description = $description;	
	}
	
	/**
	 * 设置名称
	 *
	 * @param string $name
	 */
	public function setName($name) {
		$this->name = $name;
	}
	
	/**
	 * 设置是否为可选选项
	 *
	 * @param boolean $optional 是否为可选
	 */
	public function setOptional($optional) {
		$this->optional = (boolean)$optional;
	}
	
	/**
	 * 设置是否已经定义
	 *
	 * @param boolean $defined 是否已定义
	 */
	public function setDefined($defined) {
		$this->defined = (boolean)$defined;
	}
}

?>